﻿Imports Entidades
Public Class frmModAdmin
    Private adminAnt As New Administrador
    Private adminNue As New Administrador

    Private Sub frmModAdmin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        adminAnt = miAdmin
        txtUsuario.Text = adminAnt.Usuario
        txtContraseña.Text = adminAnt.Contraseña

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If txtContraseña.Text = "" Then
            MessageBox.Show("Falta contraseña")
            Exit Sub
        End If
        If txtUsuario.Text = "" Then
            MessageBox.Show("Falta nombre de usuario")
            Exit Sub
        End If
        If txtContraseña.Text <> txtContraseña2.Text Then
            MessageBox.Show("No coinciden las contraseñas")
            Exit Sub
        End If
        Dim st As String = miGestion.ModificarAdministrador(New Administrador(txtUsuario.Text, txtContraseña.Text), adminAnt)
        If st <> "" Then
            MessageBox.Show(st)
            Exit Sub
        End If
        MessageBox.Show("Administrador modificado correctamente")
        miAdmin = miGestion.obtenerAdministrador
        Me.Close()

    End Sub
End Class